﻿using LayuiMvc.DataModel.Community;
using LayuiMvc.Logic.Community;
using LayuiMvc.Logic.LogicEnum;
using LayuiMvcUtil.Result;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;

namespace LayuiMvc.WebUI.Controllers
{
    public class HomeController : Controller
    {
        /// <summary>
        /// 帖子管理业务逻辑类
        /// </summary>
        private PostService postService = new PostService();

        public async Task<ActionResult> Index(int pageIndex=1,int pageSize=20,
            PostTypeQueryEnum postType=PostTypeQueryEnum.None,
            PostStatusQueryEnum postStatus=PostStatusQueryEnum.None,
            PostSortQueryEnum postSort = PostSortQueryEnum.New)
        {
            ViewBag.PostType = postType;
            ViewBag.PostStatus = postStatus;
            ViewBag.PostSort = postSort;

            DataResult<List<PostListModel>> rtnResult = await postService.PostListAsync(pageIndex, pageSize, postType, postStatus, postSort);

            return View(rtnResult);
        }
    }
}